<template>
	<view>
		<view class="bigbox">
			<view class="fot1">车辆详情</view>
			<view class="box1">
				<view>
					<view class="fot3">基础信息（必填）</view>
				</view>
				<!-- <view class="g_fot1">订单编号：HC2020030001</view> -->
			</view>
			<view class="box2">
				<view>品牌/车型</view>
				<input v-model="a1" type="text" placeholder="请输入">
			</view>
			<view class="box2">
				<view>车牌号</view>
				<input v-model="a2" type="text" placeholder="请输入">
			</view>
			<view class="box2">
				<view>所有人</view>
				<input v-model="a3" type="text" placeholder="请输入">
			</view>
			<view class="box2">
				<view>联系电话</view>
				<input v-model="a4" type="text" placeholder="请输入">
			</view>
			<view class="box2">
				<view>使用性质</view>
				<input v-model="a5" type="text" placeholder="请选择">
			</view>
			<view class="box2">
				<view>车架号</view>
				<input v-model="a6" type="text" placeholder="请输入">
			</view>
			<view class="box2">
				<view>发动机号</view>
				<input v-model="a7" type="text" placeholder="请输入">
			</view>
			<view class="box2">
				<view>车辆颜色</view>
				<input v-model="a8" type="text" placeholder="请输入">
			</view>
			<view class="box2">
				<view>排量(L)</view>
				<input v-model="a9" type="text" placeholder="请输入">
			</view>
			<view class="box2">
				<view>座位数</view>
				<input v-model="a10" type="text" placeholder="请输入">
			</view>
			<view class="box2">
				<view>有线</view>
				<input v-model="a11" type="text" placeholder="请输入">
			</view>
			<view class="box2">
				<view>有线SIM</view>
				<input v-model="a16" type="text" placeholder="请输入">
			</view>
			<view class="box2">
				<view>无线1</view>
				<input v-model="a12" type="text" placeholder="请输入">
			</view>
			<view class="box2">
				<view>SIM卡1</view>
				<input v-model="a13" type="text" placeholder="请输入">
			</view>
			<view class="box2">
				<view>无线2</view>
				<input v-model="a14" type="text" placeholder="请输入">
			</view>
			<view class="box2">
				<view>SIM卡2</view>
				<input v-model="a15" type="text" placeholder="请输入">
			</view>
			
			<view class="box2">
				<view>安装时间</view>
				<input v-model="a23" type="text" placeholder="请输入">
			</view>
			<view class="box2">
				<view>安装状态</view>
				<input v-model="a24" type="text" placeholder="请输入">
			</view>
			<view class="box2">
				<view>备注</view>
				<input v-model="a25" type="text" placeholder="请输入">
			</view>
			<view class="box2">
				<view>安装人</view>
				<input v-model="a26" type="text" placeholder="请输入">
			</view>
			<!--  -->
			<view class="box2">
				<view>车系</view>
				<input v-model="a33" type="text" placeholder="请输入">
			</view>
			<view class="box2">
				<view>车型</view>
				<input v-model="a34" type="text" placeholder="请输入">
			</view>
			<view class="box2">
				<view>用户城市</view>
				<input v-model="a35" type="text" placeholder="请输入">
			</view>
			<view class="box2">
				<view>安装城市名称</view>
				<input v-model="a36" type="text" placeholder="请输入">
			</view>
			<view class="box2">
				<view>GPS产品</view>
				<input v-model="a37" type="text" placeholder="请输入">
			</view>
			<view class="s_box">
				<image class="xing" src="../../static/59.png" mode=""></image>
				<text>请拍照/上传安装照片</text>
			</view>
			<view class="img_box">
				<view class="img_box1" @click="uploading(1)">
					<image :src="a17" mode=""></image>
					<!-- <view>上传正面</view> -->
				</view>
				<view class="img_box1" @click="uploading(2)">
					<image :src="a18" mode=""></image>
					<!-- <view>上传反面</view> -->
				</view>
				<view class="img_box1" @click="uploading(3)">
					<image :src="a19" mode=""></image>
					<!-- <view>上传正面</view> -->
				</view>
				<view class="img_box1" @click="uploading(4)">
					<image :src="a20" mode=""></image>
					<!-- <view>上传反面</view> -->
				</view>
				<view class="img_box1" @click="uploading(5)">
					<image :src="a21" mode=""></image>
					<!-- <view>上传正面</view> -->
				</view>
				<view class="img_box1" @click="uploading(6)">
					<image :src="a22" mode=""></image>
					<!-- <view>上传反面</view> -->
				</view>
			</view>
			<view class="box3">
				<view class="box3_1" @click="tz(1)">保存记录</view>
				<view class="box3_2" @click="tz(2)">安装提交</view>
			</view>
			<tanchuang v-if="tc_tijiao" 
			@tcnr="tanchuaung_nr"
			@tcgb="tanchuaung_gb"></tanchuang>
		</view>
		
	</view>
</template>

<script>
	import tanchuang from '../../component/tanchuang.vue'
	export default {
		data() {
			return {
				tc_tijiao:false,
				status:0,
				a1:'',
				a2:'',
				a3:'',
				a4:'',
				a5:'',
				a6:'',
				a7:'',
				a8:'',
				a9:'',
				a10:'',
				a11:'',
				a12:'',
				a13:'',
				a14:'',
				a15:'',
				a16:'',
				a17:'../../static/80.png',
				a18:'../../static/80.png',
				a19:'../../static/80.png',
				a20:'../../static/80.png',
				a21:'../../static/80.png',
				a22:'../../static/80.png',
				a23:'',
				a24:'',
				a25:'',
				a26:'',
				a33:'',
				a34:'',
				a35:'',
				a36:'',
				a37:'',
				id:'',
				rid:''
			}
		},
		onLoad:function(option){
			console.log(JSON.parse(option.item).id)
			this.rid = JSON.parse(option.item).id
			this.initial()
		},
		components:{tanchuang},
		methods: {
			tanchuaung_gb:function(data){
				this.tc_tijiao = false;
			},
			tanchuaung_nr:function(data){
				this.tz(1)
				this.$post('buse/fxjBuse_02/addFxjBuseitem_09',{
					rid:this.rid,
					query02:data.spjg,
					query03:data.spyj,
					query05:data.nbyj
				}).then((res)=>{
					if(res.data.success){
						uni.showToast({
							title:'提交成功',
							icon:'none'
						})
						setTimeout(()=>{
							uni.redirectTo({
							    url: '../yewu_order/yewu_order?type=dazgps'
							});
						},1000)
					}else if(!res.data.success){
						uni.showToast({
							title: res.data.message,
							icon:'none'
						})
					}
				})
				
			},
			uploading:function(index){
				uni.chooseImage({
				    success: (chooseImageRes) => {
				        const tempFilePaths = chooseImageRes.tempFilePaths;
						this.img = tempFilePaths[0]
				        uni.uploadFile({
				            url: this.$headUrl + 'sys/common/upload',
				            filePath: tempFilePaths[0],
				            name: 'file',
							header:{
								'X-Access-Token': uni.getStorageSync('token')
							},
				            success: (res) => {
								console.log(JSON.parse(res.data))
								if(JSON.parse(res.data).success){
									if(index == 1){
										this.a17 = JSON.parse(res.data).message
									}else if(index == 2){
										this.a18 = JSON.parse(res.data).message
									}else if(index == 3){
										this.a19 = JSON.parse(res.data).message
									}else if(index == 4){
										this.a20 = JSON.parse(res.data).message
									}else if(index == 5){
										this.a21 = JSON.parse(res.data).message
									}else if(index == 6){
										this.a22 = JSON.parse(res.data).message
									}
								}
								
				            }
				        });
				    }
				});
			},
			tz:function(e){
				if(e == 1){//保存记录
					this.baocun(0)
				}else if(e == 2){//提交
					// this.baocun(1)
					this.tijiao()
				}
			},
			tijiao:function(){
				this.tc_tijiao = true
			},
			baocun:function(e){
				let c17
				let c18
				let c19
				let c20
				let c21
				let c22
				if(this.a17 != '../../static/80.png'){c17 = this.a17}
				if(this.a18 != '../../static/80.png'){c18 = this.a18}
				if(this.a19 != '../../static/80.png'){c19 = this.a19}
				if(this.a20 != '../../static/80.png'){c20 = this.a20}
				if(this.a21 != '../../static/80.png'){c21 = this.a21}
				if(this.a22 != '../../static/80.png'){c22 = this.a22}
				this.$post('buse/fxjBuse_02/addFxjBuseitem_04',{
					rid:this.rid,
					id:this.id,
					query01:this.a1,
					query02:this.a2,
					query03:this.a3,
					query04:this.a4,
					query05:this.a5,
					query06:this.a6,
					query07:this.a7,
					query08:this.a8,
					query09:this.a9,
					query10:this.a10,
					query11:this.a11,
					query12:this.a12,
					query13:this.a13,
					query14:this.a14,
					query15:this.a15,
					query16:this.a16,
					query17:c17,
					query18:c18,
					query19:c19,
					query20:c20,
					query21:c21,
					query22:c22,
					query23:this.a23,
					query24:this.a24,
					query25:this.a25,
					query26:this.a26,
					query33:this.a33,
					query34:this.a34,
					query35:this.a35,
					query36:this.a36,
					query37:this.a37,
				}).then((res)=>{
					if(res.data.success){
						if(e == 0){
							uni.showToast({
								title:'保存成功',
								icon:'none'
							})
							uni.navigateBack({
								delta: 1
							});
						}else if(e == 1){
							console.log(11111)
							this.tijiao()
						}
					}
					console.log(res.data)
				})
			},
			orcStatus:function(e){
				this.status = e
			},
			ocr:function(){
				this.status = 1
			},
			initial:function(){
				this.$get('buse/fxjBuse_02/listFxjBuseitem_04ByMainId',{
					rid:this.rid
				}).then((res)=>{
					console.log(res.data.result.records[0],9999)
					this.id = res.data.result.records[0].id
					this.a1 = res.data.result.records[0].query01
					this.a2 = res.data.result.records[0].query02
					this.a3 = res.data.result.records[0].query03
					this.a4 = res.data.result.records[0].query04
					this.a5 = res.data.result.records[0].query05
					this.a6 = res.data.result.records[0].query06
					this.a7 = res.data.result.records[0].query07
					this.a8 = res.data.result.records[0].query08
					this.a9 = res.data.result.records[0].query09
					this.a10 = res.data.result.records[0].query10
					this.a11 = res.data.result.records[0].query11
					this.a12 = res.data.result.records[0].query12
					this.a13 = res.data.result.records[0].query13
					this.a14 = res.data.result.records[0].query14
					this.a15 = res.data.result.records[0].query15
					this.a16 = res.data.result.records[0].query16
 					if(res.data.result.records[0].query17 != '' && res.data.result.records[0].query17 != null){this.a17 = res.data.result.records[0].query17}
					if(res.data.result.records[0].query18 != '' && res.data.result.records[0].query18 != null){this.a18 = res.data.result.records[0].query18}
					if(res.data.result.records[0].query19 != '' && res.data.result.records[0].query19 != null){this.a19 = res.data.result.records[0].query19}
					if(res.data.result.records[0].query20 != '' && res.data.result.records[0].query20 != null){this.a20 = res.data.result.records[0].query20}
					if(res.data.result.records[0].query21 != '' && res.data.result.records[0].query21 != null){this.a21 = res.data.result.records[0].query21}
					if(res.data.result.records[0].query22 != '' && res.data.result.records[0].query22 != null){this.a22 = res.data.result.records[0].query22}
					this.a23 = res.data.result.records[0].query23
					this.a24 = res.data.result.records[0].query24
					this.a25 = res.data.result.records[0].query25
					this.a26 = res.data.result.records[0].query26
					this.a33 = res.data.result.records[0].query33
					this.a34 = res.data.result.records[0].query34
					this.a35 = res.data.result.records[0].query35
					this.a36 = res.data.result.records[0].query36
					this.a37 = res.data.result.records[0].query37
				})
			}
		}
	}
</script>

<style>
	.btn_all{
		margin-bottom: 30rpx;
	}
	.xing{
		width: 15rpx;
		height: 15rpx;
		margin-right: 10rpx;
	}
	.img_box1>image{
		width: 100%;
		height: 220rpx;
		margin-bottom: 30rpx;
	}
	.img_box1{
		width: 48%;
		text-align: center;
		font-size:28rpx;
		font-family:PingFang SC;
		font-weight:500;
		color:rgba(153,153,153,1);
	}
	.img_box{
		display: flex;
		justify-content: space-between;
		align-items: center;
		flex-wrap: wrap;
	}
	.s_box{
		display: flex;
		justify-content: flex-start;
		align-items: center;
		margin: 30rpx 0;
		
	}
	.g_fot1{
		color: rgba(5, 106, 255, 1);
		font-size: 24rpx;
		font-family: PingFangSC-regular;
	}
	.box3_2{
		background:rgba(66,134,245,1);
		border-radius:10rpx;
		font-size:30rpx;
		font-family:PingFang SC;
		font-weight:500;
		color:rgba(255,255,255,1);
		border:1px solid rgba(66,134,245,1);
	}
	.box3_1{
		border:1px solid rgba(66,134,245,1);
		border-radius:10rpx;
		font-size:30rpx;
		font-family:PingFang SC;
		font-weight:500;
		color:rgba(66,134,245,1);
	}
	.box3>view{
		width: 48%;
		height: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
		
	}
	.box3{
		height: 98rpx;
		display: flex;
		justify-content: space-between;
		align-items: auto;
		margin: 40rpx 0;
	}
	.box2>input{
		text-align: right;
		font-size:30rpx;
	}
	.box2{
		height:88rpx;
		background:rgba(250,250,250,0.3);
		border:1px solid rgba(230,230,230,1);
		border-radius:10rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 20rpx;
		box-sizing: border-box;
		font-size:30rpx;
		font-family:PingFang SC;
		font-weight:500;
		color:rgba(0,0,0,1);
		margin-top: 20rpx;
	}
	.zxj>image{
		width: 100%;
		height: 100%;
	}
	.zxj{
		width: 37rpx;
		height: 32rpx;
	}
	.fot3{
		font-size:22rpx;
		font-family:PingFang SC;
		font-weight:500;
		color:rgba(244,48,48,1);
	}
	.fot2{
		font-size:22rpx;
		font-family:PingFang SC;
		font-weight:500;
		color:rgba(153,153,153,1);
		margin-bottom: 19rpx;
	}
	.box1{
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.fot1{
		font-size:30rpx;
		font-family:PingFang SC;
		font-weight:bold;
		color:rgba(51,51,51,1);
		margin-bottom: 13rpx;
	}
	.bigbox{
		padding: 0 30rpx;
		box-sizing: border-box;
	}
</style>
